program upasCashDrawerCCO;
{$I \include\LogOption.txt}

//------------------------------------------------------------------------------
//  This project is intended to demonstrate how to use the UPAS interface
//    in your project.
//
//------------------------------------------------------------------------------
uses
  Forms,
  Classes,
  INI_CCOCashDrawer         in 'INI_CCOCashDrawer.pas',
  upasCashDrawerGUI         in 'upasCashDrawerGUI.pas' {upasCashDrawerForm},
  upasclientcocashdrawer    in 'upasclientcocashdrawer.pas',
  upasclientcashdrawer      in 'upasclientcashdrawer.pas',
  upasCashDrawerCCOmain     in 'upasCashDrawerCCOmain.pas',
  upasclientsocashdrawer    in 'so\upasclientsocashdrawer.pas',
  upasco                    in '..\upasco.pas',
  upasnameddevice           in '..\upasnameddevice.pas',
  upasclientco              in '..\upasclientco.pas',
  upasparam                 in '..\..\upasparam.pas',
  upasxml                   in '..\..\upasxml.pas',
  upasutils                 in '..\..\upasutils.pas',
  ParamUtil                 in '..\..\..\common\ParamUtil.pas',
  AuditLog                  in '..\..\..\common\AuditLog.pas',
  INI_Database              in '..\..\..\database\INI_Database.pas',
  idata                     in '..\..\..\industrial\idata.pas',
  INamedDeviceSocketClient  in '..\..\..\industrial\NamedDevice\INamedDeviceSocketClient.pas',
  INamedDeviceClient        in '..\..\..\industrial\NamedDevice\INamedDeviceClient.pas',
  INamedDevice              in '..\..\..\industrial\NamedDevice\INamedDevice.pas',
  IIONamedDeviceThread      in '..\..\..\industrial\NamedDevice\IIONamedDeviceThread.pas',
  IIOThread                 in '..\..\..\industrial\IIOThread.pas',
  IPollThread               in '..\..\..\industrial\IPollThread.pas',
  IOPort                    in '..\..\..\industrial\IOPort.pas',
  IOPortSocket              in '..\..\..\industrial\IOPortSocket.pas',
  INI_NamedDevice           in '..\..\..\posdevice\INI_NamedDevice.pas',
  INI_Property              in '..\..\..\property\INI_Property.pas',
  INI_Section               in '..\..\..\property\INI_Section.pas',
  blcksock                  in '..\..\..\..\3rd\ararat\source\lib\blcksock.pas',
  synafpc                   in '..\..\..\..\3rd\ararat\source\lib\synafpc.pas',
  synsock                   in '..\..\..\..\3rd\ararat\source\lib\synsock.pas',
  synautil                  in '..\..\..\..\3rd\ararat\source\lib\synautil.pas',
  synacode                  in '..\..\..\..\3rd\ararat\source\lib\synacode.pas',
  synaip                    in '..\..\..\..\3rd\ararat\source\lib\synaip.pas',
  xmlutils                  in '..\..\..\..\3rd\fpc\fcl-xml\src\xmlutils.pas',
  DOM                       in '..\..\..\..\3rd\fpc\fcl-xml\src\dom.pas',
  XMLRead                   in '..\..\..\..\3rd\fpc\fcl-xml\src\xmlread.pas',
  URIParser                 in '..\..\..\..\3rd\fpc\fcl-base\src\uriparser.pas';

{$R *.res}

var
  tmpS: TStringList;
  ctr: Integer;
begin
  Application.Initialize;
  Application.CreateForm(TupasCashDrawerForm, upasCashDrawerForm);
  upasCashDrawerForm.Emulator := False;

  tmpS := TStringList.Create;
  try
    // retrieve all command line parameters
    for ctr := 1 to ParamCount do
      tmpS.Add(ParamStr(ctr));

    // pass all command line parameters to main
    upasCashDrawerCCOmain.initialize(tmpS);

    // setup event handler, in this example, the event handler resides in the
    // gui, it performs logging, and displaying status if applicable
    upasCashDrawerCCOmain.CashDrawer.OnDirectIOEvent := upasCashDrawerForm.doDirectIOEvent;
    upasCashDrawerCCOmain.CashDrawer.OnStatusUpdateEvent := upasCashDrawerForm.doStatusUpdateEvent;

    // check some properties
    //upasCashDrawerCCOmain.CashDrawer.AutoDisable := True;
    if upasCashDrawerCCOmain.CashDrawer.CapStatus then begin
    end;


    // call some methods
    upasCashDrawerCCOmain.CashDrawer.OpenDrawer; //should trigger an event
    upasCashDrawerCCOmain.CashDrawer.WaitForDrawerClose(5000, 4000, 1000, 500);

  finally
    tmpS.Free;
  end;

  Application.Run;

  // gracefully shutdown UPAS interface
  upasCashDrawerCCOmain.finalize;
end.
